//
//  HHTwoViewController.m
//  Flower
//
//  Created by 花花 on 2016/12/6.
//  Copyright © 2016年 花花. All rights reserved.
//

#import "HHTwoViewController.h"
#import "HHScrollPageView.h"
#import "HHTest1ViewController.h"
@interface HHTwoViewController ()<HHScrollPageViewDelegate>
@property(nonatomic, strong) NSArray<NSString *> *titles;
@property(nonatomic, strong) NSArray<UIViewController *> *childVcs;
@end

@implementation HHTwoViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    //必要的设置, 如果没有设置可能导致内容显示不正常
    self.automaticallyAdjustsScrollViewInsets = NO;
    HHSegmentStyle *style = [[HHSegmentStyle alloc]init];
    //显示滚动条
    style.showLine = YES;
    //颜色渐变
    style.gradualChangeTitleColor = YES;
    //设置titles的高度
    style.segmentHeight = 35;
    
    
    self.titles = @[@"新闻头条",
                    @"国际要闻",
                    @"体育",
                    @"中国足球",
                    @"汽车",
                    @"囧途旅游",
                    @"幽默搞笑",
                    @"视频",
                    @"无厘头",
                    @"美女图片",
                    @"今日房价",
                    @"头像",
                    ];

    
    HHScrollPageView *scrollView =[[HHScrollPageView alloc]initWithFrame:CGRectMake(0, 0, screen_width, screen_height-64) segmentStyle:style titles:self.titles parentViewController:self delegate:self];
    
    [self.view addSubview: scrollView];
    
}
/** 将要显示的子页面的总数 */
-(NSInteger)numberOfChildViewControllers{

    return self.titles.count;
}



/** 获取到将要显示的页面的控制器
 * -reuseViewController : 这个是返回给你的controller, 你应该首先判断这个是否为nil, 如果为nil 创建对应的控制器并返回, 如果不为nil直接使用并返回
 * -index : 对应的下标
 */
- (UIViewController<HHScrollPageViewChildDelegate> *)childViewController:(UIViewController<HHScrollPageViewChildDelegate> *)reuseViewController forIndex:(NSInteger)index{
    UIViewController<HHScrollPageViewChildDelegate> *childvc = reuseViewController;
    if (!childvc) {
        childvc =[[HHTest1ViewController alloc]init];
        
    }

    return childvc;

}
- (BOOL)shouldAutomaticallyForwardAppearanceMethods {
    return NO;
}

@end
